
# 映射
def intersect(nums1, nums2):
    if len(nums1) > len(nums2):
        return intersect(nums2, nums1)

    m = {}
    for i in nums1:
        if not m.get(i):
            m[i] = 1
        else:
            m[i] += 1
    j = 0
    for i in nums2:
        # if  m.get(i) != None and m.get(i) != 0:
        if  m.get(i):
            nums2[j] = i
            j += 1
            m[i] -= 1
    return nums2[:j]


# 排序双指针
def intersect2(nums1, nums2):

    pass



if __name__ == '__main__':
    nums1 = [2,1]
    nums2 = [1,1]
    print(intersect(nums1,nums2))